package cn.hnh.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author HuangNianHong
 * @Time 2020/12/11 20:56
 */
@Controller
public class Blog {

    @RequestMapping(value = {"/","/page/*"})
    public String toindex(){
        return "blog/home";
    }

    @RequestMapping(value = {"/archives","/archives/*"})
    public String toarchives(){
        return "blog/archives";
    }

    @RequestMapping(value = {"/categories","/categories/*"})
    public String tocategories(){
        return "blog/categories";
    }

    @RequestMapping(value = {"/tags","/tags/*"})
    public String totags(){
        return "blog/tags";
    }

    @RequestMapping("/about")
    public String toabout(){
        return "blog/about";
    }

    @RequestMapping("/login")
    public String tologin(){
        return "admin/login";
    }

    @RequestMapping("/notfound")
    public String toerror(){
        return "error/404";
    }

    @RequestMapping("/detail/*/{description}")
    public String todeatail(@PathVariable("description")String description){
        return "blog/article_detail";
    }

    @RequestMapping("/common/")
    public String toCommonIndex(){
        return "admin/common_index";
    }

    @RequestMapping("/common/comments")
    public String toCommonComment(){
        return "admin/common_manage";
    }

    @RequestMapping("/common/self")
    public String toSelf(){
        return "admin/common_info";
    }

    @RequestMapping("/logout")
    public String Redricttologin(HttpServletResponse response){
        response.addCookie(new Cookie("x_auth_token",null));
        return "admin/login";
    }
}
